package com.common.aop;

import com.common.controller.JsonResult;
import com.common.controller.ResultCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

/**
 * @classDescription:
 * @author:xiayingjie
 * @createTime:16/8/13
 */
//拦截所有的错误
@ControllerAdvice()
public class ExceptionHandler1 {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public JsonResult hadler(HttpServletResponse response,Exception ex){
        return new JsonResult(ResultCode.EXCEPTION,ex.getMessage());
    }
}
